function [y]=FDtest(ts,D,N)
% FDtest(ts,D,N)
% 	Parameters:
% 		ts:	Time series to be shifted
% 		D:	Displacement
% 		N:	length of kernel
% 
% 	Outputs:	
% 		y	Shifted time series
% 	
% 	Purpose of this code:  This is the basic code that will take in a time seriese and use interpolation
% 	to shift it by D seconds.

%%
% USAGE: F
% DESCRIPTION: Uses fractional-delay interpolation to delay a
% sine wave by D seconds
%hold off

%% set up data
%Ndata = 200;  % length of kernel 
%t = 1:Ndata;
Ndata = length(ts);
x = ts;
y = zeros(1,Ndata);

%% plot original time series
%plot(t,x,'r');
%hold on;

%% setup filter 
%N = 101;
w = getWindow('blackman3',N,D);

Dadj = D - (N-1)/2; % adjust delay for kernel length
Dint = round(Dadj); % integer portion of delay

k = (-(N-1)/2):1:((N-1)/2); % kernel index
s = (Dadj-Dint)-k; % filter argument
F = sinc(s).*w;
n = sum(F);

%% start with integer delay 
y(Dint+1:end) = x(1:end-Dint);
%plot(t,y,'g');
%hold on;

%% do filtering

y = filter(F,1,y);

y = y./n;

%% plot interpolated time series
%plot(t,y,'--b')
%hold on;
%legend('x(t)','x(t+D)');

end
